package com.meego.common.oembed;

import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;

public class AutodiscoveredOembedProvider implements OembedProvider {
	/** The autodiscovered provider supports only one scheme... */
	private List<String> urlSchemes = new ArrayList<String>();
	private final URI apiUrl;
	private final String name;
	private String format;
	
	public AutodiscoveredOembedProvider(final String originalUrl, final URI apiUrl, final String format) {
		this.urlSchemes.add(originalUrl);
		this.apiUrl = apiUrl;
		this.name = this.apiUrl.getHost();
		this.format = format;
	}
	
	@Override
	public String getName() {
		return this.name;
	}

	@Override
	public String getFormat() {
		return this.format;
	}

	@Override
	public List<String> getUrlSchemes() {
		return this.urlSchemes;
	}

	@Override
	public URI toApiUrl(String url) throws URISyntaxException {
		return this.apiUrl;
	}
}